home *** CD-ROM | disk | FTP | other *** search
- Path: news.fsu.edu!sed!lloyd
- From: lloyd@sed.cs.fsu.edu (Justin C Lloyd)
- Newsgroups: comp.lang.c
- Subject: Re: PLEASE HELP!!!
- Date: 5 Apr 1996 11:44:57 GMT
- Organization: FSU Computer Science Department
- Message-ID: <4k313p$6oe@news.fsu.edu>
- References: <4k25rv$l4s@netnews.ntu.edu.tw>
- NNTP-Posting-Host: sed.cs.fsu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- On 5 Apr 1996 03:59:59 GMT, b3503104 (b3503104@cc.ntu.edu.tw) wrote:
- ** Please help!
-
- ** How can I write a program in C to have the similar function as "dir" in
- ** DOS? ?? (that is to LIST the files)
-
- ** Any suggestions or hints will be very helpful and appreciated!!
-
- #include <stdio.h>
-
- int main(void)
- {
- system("DIR");
- return (0);
- }
-
- Sorry, I couldn't resist. But seriously folks, for a good example of this,
- check out Stevens' book "Advanced Programming in the Unix Environment". He
- has an example of a directory tree walking program, which wouldn't be
- difficult to port over to DOS. I had to use this to implement "ls" in a
- Unix programming class, which wasn't too hard (minus having to do the damn
- columns and spacing for 'ls' with no arguments!!!!!)
-
- Also, check out dir.h in your compiler's include/sys directory (or is it
- dirent.h, I can never keep those straight.)
-
- JcL
- --
- %%%% Justin Lloyd %% lloyd@cs.fsu.edu %% http://www.cs.fsu.edu/~lloyd %%%%
- %%% in the face of the blinding sun i wake : Sarah McLachlan %%%
- %%% only to find that heaven is a stranger : -- Drawn to -- %%%
- %%% place than the world i've left behind : - the Rhythm - %%%
-